<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class Regions.
 *
 * @package namespace App\Repository\Models;
 */
class Regions extends Model implements Transformable
{
    use TransformableTrait;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $table = 'regions';

    protected $fillable = ['id','name','parent_id','short_name','level','city_code','zipcode','merger_name','ing','lat','pinyin','initial','hot','area','sort'];
    protected $appends = ['state_city_name'];

    /**
     * 只返回 省份-城市。
     * */
    public function getStateCityNameAttribute()
    {
        $state_city_name = explode(',',$this->attributes['merger_name']);
        unset($state_city_name[0]);
        $state_city_name = implode(',',$state_city_name);
        return $state_city_name;
    }
}
